<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LuckSheet online edit</title>

<link rel='stylesheet'
	th:href="@{luckysheet/dist/plugins/css/pluginsCss.css}" />
<link rel='stylesheet' th:href="@{luckysheet/dist/plugins/plugins.css}" />
<link rel='stylesheet' th:href="@{luckysheet/dist/css/luckysheet.css}" />
<link rel='stylesheet'
	th:href="@{luckysheet/dist/assets/iconfont/iconfont.css}" />
<script th:src="@{luckysheet/dist/plugins/js/plugin.js}"></script>
<script th:src="@{luckysheet/dist/luckysheet.umd.js}"></script>
<script th:src="@{luckyexcel/dist/luckyexcel.umd.js}"></script>
</head>
<body>
	<div id="luckysheet"
		style="margin: 0px; padding: 0px; position: absolute; width: 100%; height: 100%; left: 0px; top: 0px;"></div>
</body>

<script>
	$(function() {
		var name = "";
		while (name.length == 0) {
			name = prompt("请输入昵称")
		}

		var autoSave;
		//配置项
		var options = {
			lang : 'zh',
			title : '信息搜集表', // 设定表格名称
			container : 'luckysheet',
			userMenuItem: "",
			myFolderUrl: "",
			showinfobar:false,
			allowUpdate : true,
			loadUrl : "http://" + location.host + "/get",
			hook : {
				updated : function(e) {
					//监听更新,并在3s后自动保存
					if (autoSave)
						clearTimeout(autoSave)
					$(luckysheet_info_detail_save).text("已修改")
					autoSave = setTimeout(function() {
						var excel = luckysheet.getAllSheets();
						//去除临时数据,减小体积
						for ( var i in excel)
							excel[i].data = undefined
						$.post("http://" + location.host + "/set", {
							jsonExcel : JSON.stringify(excel)
						}, function() {
							$(luckysheet_info_detail_save).text("已保存")
						})
					}, 1 * 300)
					return true;
				}
			},
			updateUrl : "ws://" + location.hostname + ":11551?name=" + name
		}

		//console.log(JSON.stringify(options))
		luckysheet.create(options)
	})
</script>